home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
-
- unsigned int doWhileWithReturn( void );
- void arrayAssignmentLoop( void );
- double doubleTest( void );
-
- int main( void ) {
- unsigned int result;
- double doubleResult;
-
- arrayAssignmentLoop();
-
- result = doWhileWithReturn();
-
- printf( "doWhileWithReturn returned %d\n", result );
-
- doubleResult = doubleTest();
-
- printf( "doubleTest returned %lf\n", doubleResult );
-
- return 0;
- }
-
- void arrayAssignmentLoop( void ) {
- unsigned int count = 10;
- unsigned int array[ 10 ], item = 0;
-
- do {
- array[ item++ ] = count;
- count--;
- } while ( count > 0 );
- }
-
- unsigned int doWhileWithReturn( void ) {
- unsigned int i = 100;
- unsigned int result = 0;
- unsigned int a = 31, b = 2, c = 99;
-
- do {
- result += a * b;
- c = a * b;
- } while ( i-- > 0 );
-
- c = a * b;
-
- return result;
- }
-
- double doubleTest( void ) {
- const unsigned int limit = 100;
- double array[ limit ][ limit ], sum = 0;
- unsigned int i, j;
-
- for ( i = 0; i < limit; i++ ) {
- for ( j = 0; j < limit; j++ ) {
- array[ i ][ j ] = i;
- sum += array[ i ][ j ];
- }
- }
-
- return sum;
- }
-